//
//  BYShopCartEmptyView.m
//  OCDemo
//
//  Created by zhumuzhi on 2022/2/16.
//

#import "BYShopCartEmptyView.h"

@interface BYShopCartEmptyView ()

@property (nonatomic, strong) UIImageView   *icon;
@property (nonatomic, strong) UILabel       *title;
@property (nonatomic, strong) UILabel       *subTitle;

@end

@implementation BYShopCartEmptyView

#pragma mark - SetData
-(void)setData {
    if ([AppConfig isLogin]) {
        self.title.text = @"购物车竟然是空的";
        self.subTitle.text = @"在忙，也要记得买点什么犒劳自己~";
    }else {
        self.title.text = @"用户未登录，点击登录";
        self.subTitle.text = @"挑点喜欢的装进购物车";
    }
}

#pragma mark - Init
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.icon];
        [self addSubview:self.title];
        [self addSubview:self.subTitle];
        [self setData];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(kAutoWithSize(100));
        make.centerX.equalTo(self);
        make.width.mas_equalTo(kAutoWithSize(100));
        make.height.mas_equalTo(kAutoWithSize(100));
    }];
    
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.icon.mas_bottom).offset(kAutoWithSize(10));
        make.centerX.equalTo(self);
    }];
    
    [self.subTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.title.mas_bottom).offset(kAutoWithSize(10));
        make.centerX.equalTo(self);
    }];
    
    [super layoutSubviews];
}


#pragma mark - LazyGet
- (UIImageView *)icon {
    if (!_icon) {
        _icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"shop_cart_empty"]];
    }
    return _icon;
}

- (UILabel *)title {
    if (!_title) {
        _title = [[UILabel alloc] init];
        _title.font = MZBoldFont(18);
        _title.textColor = UIColorFromRGB(0x333333);
        _title.textAlignment = NSTextAlignmentCenter;
        _title.text = @"用户未登录，点击登录";
    }
    return _title;
}

- (UILabel *)subTitle {
    if (!_subTitle) {
        _subTitle = [[UILabel alloc] init];
        _subTitle.font = MZFont(14);
        _subTitle.textColor = [UIColor lightGrayColor];
        _title.textAlignment = NSTextAlignmentCenter;
        _subTitle.text = @"挑点喜欢的装进购物车";
    }
    return _subTitle;
}




@end
